package com.mycloud.controller;

import com.mycloud.dto.OrderDTO;
import com.mycloud.service.OrderService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by PC on 2019/1/2.
 */
@RestController
@RequestMapping("/order")

public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/createOrder")
    @HystrixCommand
    public OrderDTO createOrder(@RequestBody OrderDTO orderDTO) {
        return orderService.createOrder(orderDTO);
    }

    @PostMapping("/finish")
    public OrderDTO finishOrder(@RequestParam("orderId") String orderId) {
        return orderService.finish(orderId);
    }
}
